const MyPromise = require("../template.js")
/** 二、 状态不可变性测试 */
// 测试状态一旦改变就不可再变
function testImmutableState() {
  const promise = new MyPromise((resolve, reject) => {
    resolve(1)
    reject(new Error("Too late")) // 应被忽略
    resolve(2) // 应被忽略
  })

  promise.then(
    (value) => console.log("2. Value:", value === 1), // 应打印 true
    (reason) => console.log("2. Reason:", false)
  )
}
testImmutableState()
